package cn.com.haopy.dataes.core.system;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 系统设置
 */
public class SystemConfig {
    // 员工业务组对应短信配置
    // 采购商资质核验
    public final static String EMPLOYEE_GROUP_BUYER_AUDIT = "employee_group_buyer_audit";
    // 线下支付确认
    public final static String EMPLOYEE_GROUP_OFFLINE_PAY_AUDIT = "employee_group_offline_pay_audit";
    // 订单物流发货
    public final static String EMPLOYEE_GROUP_ORDER_SHIP = "employee_group_order_ship";

    // 订单付款超时时间（分钟）
    public final static String ORDER_PAY_DELAY = "order_pay_delay";


    // 订单自动完成收货（天）
    public final static String ORDER_TAKE_CONFIRM = "order_take_confirm";


    //所有的配置均保存在该 HashMap 中
    private static Map<String, String> SYSTEM_CONFIGS = new HashMap<>();

    private static String getConfig(String keyName) {
        return SYSTEM_CONFIGS.get(keyName);
    }

    private static Integer getConfigInt(String keyName) {
        return Integer.parseInt(SYSTEM_CONFIGS.get(keyName));
    }

    private static Boolean getConfigBoolean(String keyName) {
        return Boolean.valueOf(SYSTEM_CONFIGS.get(keyName));
    }

    private static BigDecimal getConfigBigDec(String keyName) {
        return new BigDecimal(SYSTEM_CONFIGS.get(keyName));
    }

    public static void setConfigs(Map<String, String> configs) {
        SYSTEM_CONFIGS = configs;
    }

    public static void updateConfigs(Map<String, String> data) {
        for (Map.Entry<String, String> entry : data.entrySet()) {
            SYSTEM_CONFIGS.put(entry.getKey(), entry.getValue());
        }
    }


    //
    public static Integer getEmployeeGroupBuyerAudit() {
        return getConfigInt(EMPLOYEE_GROUP_BUYER_AUDIT);
    }

    public static Integer getEmployeeGroupOfflinePayAudit() {
        return getConfigInt(EMPLOYEE_GROUP_OFFLINE_PAY_AUDIT);
    }

    public static Integer getEmployeeGroupOrderShip() {
        return getConfigInt(EMPLOYEE_GROUP_ORDER_SHIP);
    }

    public static Integer getOrderPayDelay() {
        return getConfigInt(ORDER_PAY_DELAY);
    }


    public static Integer getOrderTakeConfirm() {
        return getConfigInt(ORDER_TAKE_CONFIRM);
    }
}